import { mapGetters } from 'vuex'

export const methodsMixins = {
  computed: {
    ...mapGetters(['dictList'])
  },
  methods: {
    formatDictCode(code, val) {
      // eslint-disable-next-line eqeqeq
      const target = this.dictList.find(item => item.code == code)
      if (target && (val || val === 0 || val === '0')) {
        let res = ''
        val
          .toString()
          .split(',')
          .forEach((item, index) => {
            // eslint-disable-next-line eqeqeq
            const a = target.children.find(item1 => item1.code == item)
            if (a) {
              res += `${index === 0 ? '' : '、'}${a.name}`
            } else {
              res += ''
            }
            // eslint-disable-next-line eqeqeq
          })
        return res
      }
      return '-'
    },
    getDictListByCode(code){
      const target = this.dictList.find(item => item.code == code)
      return target
    }
    
  }
}
